<?php
require './model/Db.php';
$Db = DB::getInstance();
$isMobile = preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT']);
$user_data = $Db->islogin();
if(!$user_data){
	header('Location:err.php?id=2');
}
if(isset($_POST['submit'])){
	$_POST = $Db->escape($_POST);
	if($_POST['nick'] != $user_data['nick'] || $_POST['qianming'] != $user_data['qianming'] || $_POST['sex'] != $user_data['sex'] || $_POST['phone'] != $user_data['phone']){
		$Db->update([
			table => 'bbs_user',
			map => [
				nick => $_POST['nick'],
				sex => $_POST['sex'],
				qianming => $_POST['qianming'],
				phone => $_POST['phone']
			],
			where => "`id` = {$user_data['id']}"
		]);
	}
$web_title = '跳转...';
$msg = '修改成功';
$reurl = '';
include './view/skip.html';
}else{
    $reqtype = $_COOKIE['reqtype'] ? $_COOKIE['reqtype']:'home';
	//获取发帖数
	$count = $Db->count([
		table => ['content'],
		where => "`uid` = {$user_data['id']}"
	]);
$web_title = $user_data['user'].'的个人中心';
$css = [
	'public/css/my-bootstrap.min.css',
	'public/css/usercenter.all.min.css'
];
include './view/header.html';
include './view/usercenter.all.html';
include './view/footer.html';
}
$Db->close();
